package cn.com.pansky.util;

import java.io.IOException;
import java.util.Properties;

public class PropertiesUtil {

	static Properties p = new Properties();
	public PropertiesUtil() {
		try {
			p.load(getClass().getClassLoader().getResourceAsStream("config.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 根据properties中的key获取value
	 * @param key
	 * @return
	 */
	public static String getValue(String key) {
		new PropertiesUtil();
		return p.getProperty(key);
	}
	
	/**
	 * 农行支付根据商户号返回索引,农行用
	 * @return
	 */
	public int getabcAAE051(String aae051) {
		Properties properties = new Properties();
		try {
			properties.load(getClass().getClassLoader().getResourceAsStream("TrustMerchant.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		String merchant = properties.getProperty("MerchantID");
		String[] array = merchant.split(",");
		for(int i = 0; i < array.length; i++) {
			if(aae051.equals(array[i])) {
				return i+1;
			}
		}
		return 0;
	}
}
